package com.xiaozheng.mybatis.SqlSession.defaults;

import com.xiaozheng.mybatis.SqlSession.SqlSession;
import com.xiaozheng.mybatis.SqlSession.SqlSessionFactory;
import com.xiaozheng.mybatis.cfg.Configuration;

/**
 * @Package: com.xiaozheng.mybatis.SqlSession.defaults
 * @ClassName: DefaultSqlSessionFactory
 * @Author: 小政同学    QQ:xiaozheng666888@qq.com
 * @CreateTime: 2020/8/28 12:40
 * @What_is_this_file_for: SqlSessionFactory的实现类
 * @Description: 提供SqlSession方法
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {
    private Configuration cfg;

    public DefaultSqlSessionFactory(Configuration cfg) {
        this.cfg = cfg;
    }
    /**
     * 用于创建一个新的操作数据库对象
     * @return
     */
    @Override
    public SqlSession openSession() {
        return new DefaultSqlSession(cfg);
    }
}
